package org.yinxianren.www.study_02.study.arithmetic;

import edu.princeton.cs.algs4.*;

public class DemoInteral2D {

    public static void main(String[] args) {

        double xlo=2.0;
        double xhi=50.0;
        double ylo=50.0;
        double yhi=60.0;
        int T=10000;
        Interval1D xinteraval=new Interval1D(xlo,xhi);
        Interval1D yinteraval=new Interval1D(ylo,yhi);
        Interval2D box=new Interval2D(xinteraval,yinteraval);
        box.draw();

        Counter c= new Counter("hits");
        for(int t=0;t<T;t++){
            double x= Math.random();
            double y= Math.random();
            Point2D p= new Point2D(x,y);
            if(box.contains(p)) c.increment();
            else p.draw();
        }
        StdOut.println(c);
        StdOut.println(box.area());

    }

}
